package com.woniuxy.kaer.user.controller;


import com.woniuxy.kaer.commons.util.PageInfo;
import com.woniuxy.kaer.commons.util.Result;
import com.woniuxy.kaer.user.model.PointsLog;
import com.woniuxy.kaer.user.service.PointsLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sun
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/pointsLog")
@Api(tags = "积分日志管理")
public class PointsLogController {
    @Resource
    private PointsLogService pointsLogService;

    @ApiOperation(value = "查询所有积分日志")
    @GetMapping("/list")
    public Result allList() {
        List<PointsLog> pointsLogs = pointsLogService.list();
        return Result.succeed("查询所有积分列表成功",pointsLogs);
    }
    /**
     * 新增积分日志
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增积分日志", notes = "新增积分日志记录")
    @ApiResponses({
            @ApiResponse(code = 200, message = "新增成功"),
            @ApiResponse(code = 500, message = "服务器内部错误")
    })
    public Result add(@RequestBody PointsLog pointsLog) {
        pointsLogService.save(pointsLog); // 保存积分日志
        return Result.succeed("新增积分日志成功", null);
    }

}

